package com.ita.service.impl;

import javax.annotation.Resource;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ita.activemq.Sender;
import com.ita.dao.CustomerDao;
import com.ita.pojo.Customer;
import com.ita.service.CustomerService;
import com.ita.service.MQService;

@Service(value = "customerService")
public class CustomerServiceImpl implements CustomerService {

	@Autowired(required = true)
	private CustomerDao cDao;

	@Autowired(required = true)
	private Sender sender;

	@Resource(name = "jmsTemplate")
	private JmsTemplate jmsTemplate;
	
	@Override
	@Transactional
	public int regist(Customer c) {

		Customer customer = cDao.addUser(c);
		sender.sendMessage("123");
		if (customer != null)
			return 1;
		else
			return 0;
	}

	@Override
	public int login(String userName, String password) {

		Customer customer = cDao.findByName(userName);
		if (password.equals(customer.getPassword()))
			return 1;
		else
			return 0;

	}


}
